// 配置路由
import Vue from "vue"
import Router from 'vue-router';

//使用Router
Vue.use(Router)
// 路由配置
const list = [
    // 每个路由的配置信息
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/home',
        //当访问/home时展示那个组件
        component: () => import('@/views/home/home.vue'),
        redirect: '/home/list',
        children: [{
                path: 'list', // 完整地址：/home/list
                component: () => import('@/views/home/children/list.vue')
            },
            {
                name: 'ProductDetail',
                path: 'detail:id', // 完整地址：/home/detail
                component: () => import('@/views/home/children/detail.vue')
            }
        ]
    },
    {
        path: '/type/:categoryId?',
        name: 'Type',
        component: () => import('@/views/type/type.vue')
      },
    {   path: '/cart',
        component: () => import('@/views/cart/cart.vue')
    },
    {
        path: '/my',
        component: () => import('@/views/my/index.vue'), // 懒加载 my/index 组件
        redirect: '/my/center',
        children: [
          {
            path: 'center',
            component: () => import('@/views/my/children/center.vue') // 懒加载 my/children/center 组件
          },
          {
            path: 'set',
            component: () => import('@/views/my/children/set.vue') // 懒加载 my/children/set 组件
          }
        ]
      },
      {
        path: '/order', //订单的父路由
        component: () => import('../views/order/order.vue'),
        //重定向
        redirect: '/order/list',

        //配置订单的子路由
        children: [{
                path: 'list', //完整路径/order/list
                component: () => import('../views/order/children/list.vue')
            },
            {
                path: 'detail', //完整路径/order/detail
                component: () => import('../views/order/children/detail.vue')
            },
            {
                path: 'verify', //完整路径/order/verify
                component: () => import('../views/order/children/verify.vue')
            },
            {
                path: 'pay', //完整路径/order/pay
                component: () => import('../views/order/children/pay.vue')
            },
        ]
    },
    {
        path:"/login",
        component: ()=>import('@/views/account/index.vue')
    },
    {
        path: '/history',
        //当访问/home时展示那个组件
        component: () => import('../views/history/history.vue')
    },
    
    {
        path: '/components',
        //当访问/home时展示那个组件
        component: () => import('../views/components/Footer.vue')
    },{
        path:'*',
        component: ()=>import('@/views/NotFound.vue')
    },
    // {   path: '/demo',
    //     component: () => import('@/views/demo/demo.vue')
    // },
]
export default new Router({
    mode:'history',
    routes: list
   });